const CarModel = require('../models/CarModel')

const carService = {
  getCarListByShop(shop_id) {
    return CarModel.find({
      shop_id,
    })
      .populate('category_id')
      .populate('type_id')
  },
  addCar(data) {
    return CarModel.create(data)
  },
  updateCar(_id, data) {
    return CarModel.updateOne(
      {
        _id,
      },
      {
        $set: data,
      }
    )
  },
  deleteCar(_id) {
    return CarModel.deleteOne({
      _id,
    })
  },
}

module.exports = carService
